package com.ticket.sass.common.entity.tenant.enums

import com.baomidou.mybatisplus.annotation.IEnum

enum class CommodityCloudPrinterType(private val value: Short, val tips: String) : IEnum<Short> {
    EASY_JOIN_CLOUD(1, "易联云");

    override fun getValue(): Short {
        return value
    }

    companion object {
        fun valueOf(v: Short) = values().find { it.value == v } ?: error("未匹配到枚举")
    }

    fun isConfigValid(jumpConfig: Map<String, String>?): Boolean {
        return when (this) {
            EASY_JOIN_CLOUD -> jumpConfig != null &&
                    jumpConfig.containsKey("clientId") &&
                    jumpConfig.containsKey("clientSecret") &&
                    jumpConfig.containsKey("machineCode") &&
                    jumpConfig.containsKey("msign") &&
                    jumpConfig.size == 4
        }
    }
}
